﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.TcCommands.TcCheckoutCheckin.CUiTcCheckoutDialog
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using Tecnomatix.Engineering.Ui.WPF;


namespace DnProcessSimulateCommands.TcCommands.TcCheckoutCheckin;

public class CUiTcCheckoutDialog : TxWindow, IComponentConnector
{
  private static bool _includeSubHierarchies = true;
  private static bool _includeWorkareasAndResources = true;
  internal GroupBox gbAdditionalCoObjects;
  internal CheckBox cbIncludeSubHierarchies;
  internal CheckBox cbIncludeWorkareasAndResources;
  internal Button btnOk;
  internal Button btnCancel;
  private bool _contentLoaded;

  public CUiTcCheckoutDialog(bool showIncludeWorkareasAndResources)
  {
    this.InitializeComponent();
    if (showIncludeWorkareasAndResources)
      return;
    this.cbIncludeWorkareasAndResources.Visibility = Visibility.Collapsed;
    ((UIElement) this).Refresh();
  }

  public static bool IncludeSubHierarchies
  {
    get => CUiTcCheckoutDialog._includeSubHierarchies;
    set => CUiTcCheckoutDialog._includeSubHierarchies = value;
  }

  public static bool IncludeWorkareasAndResources
  {
    get => CUiTcCheckoutDialog._includeWorkareasAndResources;
    set => CUiTcCheckoutDialog._includeWorkareasAndResources = value;
  }

  private void TxWindow_Initialized(object sender, EventArgs e)
  {
    this.cbIncludeSubHierarchies.IsChecked = new bool?(CUiTcCheckoutDialog.IncludeSubHierarchies);
    this.cbIncludeWorkareasAndResources.IsChecked = new bool?(CUiTcCheckoutDialog.IncludeWorkareasAndResources);
    this.HandleCbIncludeSubHierarchiesStateChanged(CUiTcCheckoutDialog.IncludeSubHierarchies);
  }

  private void btnOk_Click(object sender, RoutedEventArgs e)
  {
    ((Window) this).DialogResult = new bool?(true);
    CUiTcCheckoutDialog.IncludeSubHierarchies = this.cbIncludeSubHierarchies.IsChecked.Value;
    CUiTcCheckoutDialog.IncludeWorkareasAndResources = this.cbIncludeWorkareasAndResources.IsChecked.Value;
    ((Window) this).Close();
  }

  private void btnCancel_Click(object sender, RoutedEventArgs e)
  {
    ((Window) this).DialogResult = new bool?(false);
    ((Window) this).Close();
  }

  private void HandleCbIncludeSubHierarchiesStateChanged(bool isChecked)
  {
    this.cbIncludeWorkareasAndResources.IsEnabled = isChecked;
  }

  private void cbIncludeSubHierarchies_Checked(object sender, RoutedEventArgs e)
  {
    this.HandleCbIncludeSubHierarchiesStateChanged(true);
  }

  private void cbIncludeSubHierarchies_Unchecked(object sender, RoutedEventArgs e)
  {
    this.HandleCbIncludeSubHierarchiesStateChanged(false);
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  public void InitializeComponent()
  {
    if (this._contentLoaded)
      return;
    this._contentLoaded = true;
    Application.LoadComponent((object) this, new Uri("/DnProcessSimulateCommands;component/tccommands/tccheckoutcheckin/cuitccheckoutdialog.xaml", UriKind.Relative));
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  [EditorBrowsable(EditorBrowsableState.Never)]
  void IComponentConnector.Connect(int connectionId, object target)
  {
    switch (connectionId)
    {
      case 1:
        ((FrameworkElement) target).Initialized += new EventHandler(this.TxWindow_Initialized);
        break;
      case 2:
        this.gbAdditionalCoObjects = (GroupBox) target;
        break;
      case 3:
        this.cbIncludeSubHierarchies = (CheckBox) target;
        this.cbIncludeSubHierarchies.Checked += new RoutedEventHandler(this.cbIncludeSubHierarchies_Checked);
        this.cbIncludeSubHierarchies.Unchecked += new RoutedEventHandler(this.cbIncludeSubHierarchies_Unchecked);
        break;
      case 4:
        this.cbIncludeWorkareasAndResources = (CheckBox) target;
        break;
      case 5:
        this.btnOk = (Button) target;
        this.btnOk.Click += new RoutedEventHandler(this.btnOk_Click);
        break;
      case 6:
        this.btnCancel = (Button) target;
        this.btnCancel.Click += new RoutedEventHandler(this.btnCancel_Click);
        break;
      default:
        this._contentLoaded = true;
        break;
    }
  }
}
